package com.xuecheng.content.api;

import com.xuecheng.base.exception.ValidationGroups;
import com.xuecheng.content.model.po.CourseTeacher;
import com.xuecheng.content.service.CourseTeacherService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseTeachController {

    @Autowired
    CourseTeacherService courseTeacherService;

    @ApiOperation("查询教师信息")
    @GetMapping("/courseTeacher/list/{courseId}")
    public List<CourseTeacher> ListTeacherInfo(@PathVariable Long courseId){
        return courseTeacherService.selectTeacherList(courseId);
    }

    @ApiOperation("添加/修改教师信息")
    @ApiImplicitParam(value = "teacherDto",required = true,dataType = "Json",paramType = "Body")
    @PostMapping("/courseTeacher")
    public CourseTeacher addCourseTeacher(@RequestBody @Validated(ValidationGroups.Insert.class) CourseTeacher courseTeacherDto){
        Long companyId= 1232141425L;
        return courseTeacherService.saveOrEdit(companyId,courseTeacherDto);
    }



    @ApiOperation("删除教师")
    @DeleteMapping("/courseTeacher/course/{courseId}/{courseTeacherId}")
    public void deleteTeacherInfo(@PathVariable Long courseId,@PathVariable Long courseTeacherId){
        Long companyId=1232141425L;
        courseTeacherService.deleteTeacherInfo(courseId,courseTeacherId,companyId);
    }


}
